<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>

<%
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
            + request.getContextPath() + "/";
    request.setAttribute("basePath", basePath);
%>
<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>后台管理系统</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="${basePath}css/font.css">
    <link rel="stylesheet" href="${basePath}css/xadmin.css">
    <script type="text/javascript" src="${basePath}js/jquery-3.3.1.min.js"></script>
    <script type="text/javascript" src="${basePath}lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${basePath}js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
    <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
    <link rel="stylesheet" href="${basePath}css/xcConfirm.css" type="text/css">
    <script src="${basePath}js/xcConfirm.js"></script>
    <script src="${basePath}lib/My97DatePicker/WdatePicker.js"></script>
</head>
<script>
    $(function () {
        try {
            var index = parent.layer.getFrameIndex(window.name);
            window.parent.location.reload();
            parent.layer.close(index);
        } catch (e) {

        }
    });
</script>
<body>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so layui-form-pane"  method="get">
            <input class="layui-input" placeholder="优惠券名称" name="title" value="${page.conMap.title}">
            <div class="layui-input-inline">
                <select name="ftype">
                    <option value="">优惠券类型</option>
                    <option value="-1" ${page.conMap.ftype == "-1" ? 'selected="selected"' : '' }>全部</option>
                    <option value="0" ${page.conMap.ftype == 0 ? 'selected="selected"' : '' }>抵扣券</option>
                    <option value="1" ${page.conMap.ftype >= 1 ? 'selected="selected"' : '' }>满减</option>
                </select>
            </div>
            <div class="layui-input-inline">
                <select name="limits">
                    <option value="">适用范围</option>
                    <option value="1" ${page.conMap.limits == 1 ? 'selected="selected"' : '' }>全场</option>
                    <option value="2" ${page.conMap.limits == 2 ? 'selected="selected"' : '' }>课程</option>
                    <option value="3" ${page.conMap.limits == 3 ? 'selected="selected"' : '' }>章节</option>
                    <option value="4" ${page.conMap.limits == 4 ? 'selected="selected"' : '' }>年卡</option>
                </select>
            </div>
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <xblock>
        <button class="layui-btn" lay-filter="sreach"
                onclick="x_admin_show('增加','${basePath}Coupons/CouponsLoad/0')">
            <i class="layui-icon"></i>增加
        </button>
        <span class="x-right" style="line-height:40px">共有数据：${page.totalCount} 条</span>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <td>序号</td>
            <td>优惠券标题</td>
            <td>面值</td>
            <td>优惠券类型</td>
            <td>适用范围</td>
            <td>使用范围详情</td>
            <td>有效天数(单位：天)</td>
            <td>更新时间</td>
            <td>操作</td>
        </tr>
        </thead>
        <tbody>
        <c:if test="${not empty page.results}">
            <c:forEach items="${page.results}" var="result" varStatus="vs">
                <tr>
                    <td>${(page.actulPageNo -1)*15+vs.count} </td>
                    <td>${result.title}</td>
                    <td>${result.cost}</td>
                    <td>
                        <c:choose>
                            <c:when test="${result.ftype eq '0'}">抵扣券</c:when>
                            <c:otherwise>满${result.ftype}可用</c:otherwise>
                        </c:choose>
                    </td>
                    <td>
                        <c:if test="${result.limits eq '1'}">全场</c:if>
                        <c:if test="${result.limits eq '2'}">课程</c:if>
                        <c:if test="${result.limits eq '3'}">章节</c:if>
                        <c:if test="${result.limits eq '4'}">年卡</c:if>
                    </td>
                    <td><a style="cursor:pointer;" href="<%=basePath %>/Coupons/CouponsLoad/${result.id}">点击查看详情</a>
                    </td>
                    <td>${result.valid_date }</td>
                    <td>${result.update_time}</td>
                    <td>
                        <button class="layui-btn layui-btn layui-btn-xs"
                                onclick="x_admin_show('编辑','${basePath}Coupons/CouponsLoad/${result.id}')">
                            <i class="layui-icon">&#xe642;</i>编辑
                        </button>
                        <button class="layui-btn-danger layui-btn layui-btn-xs" onclick="_del('${result.id}')"
                                href="javascript:;"><i class="layui-icon">&#xe640;</i>删除
                        </button>
                    </td>
                </tr>
            </c:forEach>
        </c:if>
        </tbody>
    </table>
    <div class="page">
        <c:if test="${page.totalPageNo > 1 }">
            <div>
                <a class="num" href='${basePath}${page.url}?pageNo=1${page.params}'>首页</a>
                <c:if test="${page.actulPageNo > 1 }">
                    <a class="prev"
                       href='${basePath}${page.url}?pageNo=${page.actulPageNo - 1}${page.params}'>上一页</a>
                </c:if>
                <c:forEach var="pno" items="${page.showNums }">
                    <c:choose>
                        <c:when test="${pno == page.actulPageNo}">
                            <span class="current"> ${pno }</span>
                        </c:when>
                        <c:otherwise>
                            <c:if test="${not empty pno}">
                                <a class="num"
                                   href='${basePath}${page.url}?pageNo=${pno  }${page.params}'>${pno }</a>
                            </c:if>
                        </c:otherwise>
                    </c:choose>
                </c:forEach>
                <c:if test="${page.actulPageNo  < page.totalPageNo }">
                    <a class="next" href='${basePath}${page.url}?pageNo=${page.actulPageNo + 1}${page.params}'>下一页</a>
                </c:if>
                <a class="num" href='${basePath}${page.url}?pageNo=${page.totalPageNo }${page.params}'>尾页</a>
            </div>
        </c:if>
    </div>
</div>
<script>
    layui.use(['form'], function () {
        form = layui.form;

    });

    function _del(id) {
        layer.confirm('确认要删除吗？', function () {
            var url = "${basePath}Coupons/CouponsDel/" + id;
            location.href = url;
        });
    }

    function designated(id) {
        var url = "${basePath}adInfo/AdInfoTop/" + id;
        location.href = url;
    }
</script>
</body>

</html>